<template>
  <div class="pages">
    <getCartDetail :isMeIndex="isMeIndex"></getCartDetail>
    <!-- <ul class="box" >
      <li v-if="isSc&&options.btnStatus==0"  >

         <p style="font-size: 28rpx;" @click="scFun" v-if="!isScSuccess">收藏名片</p>
      </li>
      <li v-if="isSc&&options.btnStatus==2"  >
     
        <p style="font-size: 28rpx;">已收藏</p>

      </li>

    </ul> -->
    <getUserinfo ref="getUserinfo"  :empId="empId" ></getUserinfo>
  </div>
</template>

<script>
  import getCartDetail from "../../components/getCartDetail.vue"
  export default{
    data(){
      return {
       isOpen:true,
          isMeIndex:false,
       isSc:true,
          empId:"",
        options:{},
        isScSuccess:false
      }
    },
      onLoad(options){
      this.options=options
        this.empId=options.empId;

      },
      onShow(){
          wx.setNavigationBarTitle({
              title: '商品'
          })
      },
      methods:{
          scFun(){
              let userInfo = wx.getStorageSync('userInfo')
              let cartId=wx.getStorageSync('cartId')
            let userId=wx.getStorageSync('userId1')
              if(userInfo){
                  wx.setStorageSync('isEdit', 0)
                  this.$http.request({
                      method:"post",
                      url:"/api/cardForward/add",
                      body:{
                        "cardLogo":this.options.img,
                          "cardId": cartId,


                          // "empId":this.empId,
                          "forwarderId":this.empId,

                          "type": 3,
                          "userId": userId
                      }
                  }).then((data)=>{
                      if(data.code==200){
                          this.isScSuccess=true;
                          wx.showToast({
                              title: '收藏成功',
                              icon: 'success',
                              duration: 2000

                          })
                      }else{
                          this.scActive=false;
                          wx.showToast({
                              title: '收藏失败',
                              icon: 'none',
                              duration: 2000

                          })
                      }
                  }).catch(()=>{
                      this.isScSuccess=false;
                  })

              }else{
                this.$refs.getUserinfo.init(this.empId)
              }




          },
      },
    components:{
      getCartDetail
    }
  }
</script>

<style scoped>
  .box{
    width: 74rpx;
    height: 120rpx;
    background-color: #fff;

    /* border: 1px solid rgb(61,176,243); */
    border-radius: 30rpx;
    position: fixed;
    top:50%;
    right: 5%;
    font-size: 22rpx;
    border:1px solid rgb(61,176,243);
    /*display: flex;*/
    /*justify-content: center;*/
    /*align-content: center;*/
    /*flex-wrap: wrap;*/
    text-align: center;
    transform :translateY(-60rpx);
  }
  .box>li{
    width: 100%;
    height:57%;
    margin-top:22%;
  }
  #share{
    width: 100%;
    height: 100%;
    background-color: #fff;
    border:none;
    padding-left: 0;
    padding-right: 0;
    font-size: 24rpx;

  }
  #share:after{
    border:none;
  }
  .box>li:first-child{
    /*margin-bottom: 10rpx;*/
  }
  .box img{
    width: 40rpx;
    height: 40rpx;
  }
</style>
